package edu.ustb.efws.security;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * 用户认证凭证
 *
 * @author TS Group
 */
public class Credential {
    private final Long id;
    private final String username;
    private final String[] roles;
    private final boolean manage;

    /**
     * 构造{@link Credential}
     *
     * @param id 用户编号
     * @param username 用户名
     * @param roles 用户拥有角色集合
     * @param manage 管理端授权
     */
    public Credential(Long id, String username, String[] roles, boolean manage) {
        this.id = id;
        this.username = username;
        this.roles = roles;
        this.manage = manage;
    }

    public Long getId() {
        return id;
    }

    public String getUsername() {
        return username;
    }

    public String[] getRoles() {
        return roles;
    }

    public boolean isManage() {
        return manage;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("id", id)
                .append("username", username)
                .append("roles", roles)
                .append("manage", manage)
                .toString();
    }
}
